<?php

namespace App\Http\Requests\Company\Register;
use App\Http\Requests\Request;

class OrdinaryRegisterRequest extends Request {
    public function authorize(){
        return true;
    }
    public function rules(){
        $input = $this->all();
        return [
            'company_name' => 'required',
            'contacts' => 'required',
            'email' => 'email',
            'phone' => 'check_phone:'.$this->area_code.','.$this->ext,
            'username' => 'required|max:20|alpha_dash|unique:company_users,username|mobile',
            'password' => 'required|between:6,20|confirmed',
            'code' => 'required|captcha',
        ];
    }
    public function messages(){
        return [
            'company_name.required' => '公司名称必须填写',
            'contacts.required' => '联系人必须填写',
            'email.email' => '邮箱格式不正确',
            'phone.check_phone' => '电话号码不正确',
            'username.required' => '用户名必须填写',
            'username.alpha_dash' => '用户名可以允许字母、数字、底线_',
            'username.unique' => '该用户名已存在',
            'username.max' => '用户名称最多20个字符',
            'username.mobile' => '用户名不能使用手机号码',
            'password.required' => '密码必须填写',
            'password.between' => '密码必须在6-20位之间',
            'password.confirmed' => '确认密码和密码必须一致',
            'code.required' =>'验证码不能为空！',
            'code.captcha' => '验证码错误，请重新输入'
        ];
    }
}